package com.xingchen.springboot3.config;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author weijingchen
 * @DateTime 2025-09-24
 */
public class CommonImportSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        List<String> list = new ArrayList<>();
        try (InputStream is = CommonImportSelector.class.getClassLoader().getResourceAsStream("common.properties");
             BufferedReader bis = new BufferedReader(new InputStreamReader(is));) {
            String line;
            while ((line = bis.readLine()) != null) {
                list.add(line);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return list.toArray(new String[0]);
    }
}
